//index.js
//获取应用实例
const app = getApp();
Page({
  data: {
  	phone:''
  },
  onLoad () { },
  onReady () {} ,
  handlBtn (){
  	let url = app.globalData.url.RegisterYzm;
    var testPhone = /^[1][3,4,5,7,8][0-9]{9}$/;
    var phone = this.data.phone
    if (!testPhone.test(phone)){
    	wx.showToast({title:'手机格式错误',icon:'none'})
    }else{
    	wx.request({
		    url: url,
		    data: {
		        "cfrom": app.globalData.cfrom,
		        "version": "1",
		        "phone": phone
		    },
		    method: "GET",
		    success(res) {
		        let code = res.statusCode
		        if (code == '200') {
		          let data = res.data
		          if (data.status == '_0000') {
			            //未注册
			            wx.showToast({title:'请先注册',icon:'none'})
			            setTimeout(function () {
			            	wx.navigateTo({url:'../registerPassword/index?phone=' + phone})
			            }, 1500);
		       	 }else if (data.status == "1001") {
		            //已注册
		            wx.navigateTo({url:'../loginPassword/index?phone=' + phone})
		         } else {
	          	   wx.showToast({title:data.message,icon:'none'})
	          	 }
		      }
		  	}
	    })
    }
    
  },
  inputPhone(e) {
	   this.setData({
	      phone: e.detail.value
	    })
  },
  goHome () {
  	wx.navigateTo({url:'../index/index'})
  }
})
